# Maintainer: Stacy Harper <contact@stacyharper.net>
pkgname=kakoune-cr
pkgver=0.0.2
pkgrel=0
pkgdesc="kakoune.cr (kcr) is a command-line tool for Kakoune"
url="https://github.com/alexherbo2/kakoune.cr"
arch="x86_64 aarch64" # limited by crystal
license="MIT"
depends="jq"
makedepends="crystal shards"
_commit="d2b59774382328343cb4e6336f371e15d2a84b96"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/alexherbo2/kakoune.cr/archive/$_commit.tar.gz
	kcr.kak
"
builddir="$srcdir/kakoune.cr-$_commit"
subpackages="$pkgname-commands"

build() {
	make build
}

package() {
	install -Dm755 bin/kcr "$pkgdir"/usr/bin/kcr

	cd share/kcr
	find init/ pages/ -type f -exec install -Dm644 "{}" "$pkgdir/usr/share/kcr/{}" \;

	install -Dm644 applications/kcr.desktop "$pkgdir"/usr/share/applications/kcr.desktop

	mkdir -p "$pkgdir"/usr/share/kak/autoload/kcr
	install -Dm644 "$startdir"/kcr.kak "$pkgdir"/usr/share/kak/rc/kcr/kcr.kak

}

commands() {
	depends="$depends fd fzf"

	cd "$builddir"/share/kcr
	find commands/ -type f -name 'kcr-*' | while read file; do
		install -Dm755 "$file" "$subpkgdir/usr/bin/$(basename "$file")"
	done
}

sha512sums="
e57ae8dcdf51a1ffaeee834dd93c006ffd94200c0fe47d1647180ac2597e2be8abda1edff647af2d31774f7fb3174a6cb5c27049620fdf011f8ad982403b800b  kakoune-cr-0.0.2.tar.gz
5d44426f8829e07c34ac6e3b5a483f0103da5d9648d1705636df5f273bb35d81935474545240359455d6837461b54cef860f461ee52dfa3fddbf3233efded94f  kcr.kak
"
